<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<#assign DutyDept = JspTaglibs["http://www.casic304.cn/DutyDept"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>外协外购产品检验信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <style>
        .layui-input-block {
            margin-left: 115px;
        }
        .table-top-filter .layui-form-label {
            width: 112px;
        }
    </style>
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="wQbdOutsourceCheckTable" lay-filter="wQbdOutsourceCheckTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wQbdOutsourceCheckHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="xzan_wxwgcpjyxx302" css="layui-btn layui-btn-sm fillBtn" event="add">
                <span>新增</span>
            </@f.a>
            <@f.a alias="scan_wxwgcpjyxx302" css="layui-btn layui-btn-sm" event="delete">
                <span>删除</span>
            </@f.a>
            <a class="layui-btn layui-btn-sm" lay-event="export">
                <span>导出</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="wQbdOutsourceCheckQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">编号</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_productnum_SL" placeholder="编号"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号</label>
                        <div class="layui-input-block">
                            <select class="layui-input filter-value" name="Q_model_S" lay-filter="xh"
                                    lay-verify="required" lay-search="" placeholder="请输入"/></select>
                        </div>
                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">产品名称</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input filter-value" name="Q_productname_SL" placeholder="产品名称"/>
                                        </div>
                                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">开始下厂验收时间</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input start_time1 filter-value" name="Q_beginCheckdate_DL" placeholder="开始下厂验收时间"/>
                                        </div>
                                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">结束下厂验收时间</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input end_time1 filter-value" name="Q_endCheckdate_DE" placeholder="结束下厂验收时间"/>
                                        </div>
                                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">验收结论</label>
                                        <div class="layui-input-block">
                                            <select class="layui-input filter-value" lay-verify="required" lay-search=""
                                                    name="checkresult" placeholder="请输入"/></select>
                                        </div>
                                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">复验结论</label>
                                        <div class="layui-input-block">
                                            <select class="layui-input filter-value" lay-verify="required" lay-search=""
                                                    name="recheckresult" placeholder="请输入"/></select>
                                        </div>
                                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">开始入所复验时间</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input start_time2 filter-value" name="Q_beginRecheckdate_DL" placeholder="开始入所复验时间"/>
                                        </div>
                                    </div>
                                    <div class="qbdms-listForm">
                                        <label class="layui-form-label">结束入所复验时间</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input end_time2 filter-value" name="Q_endRecheckdate_DE" placeholder="结束入所复验时间"/>
                                        </div>
                                    </div>
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wQbdOutsourceCheckRightToolsBar">
    {{# if('${currentUserId}'==d.createBy){ }}
    <@f.a alias="xgan_wxwgcpjyxx302" event="edit" css="RightBtn">编辑</@f.a>
    {{#  } }}
    <@f.a alias="qqan_wxwgcpjyxx302" event="particulars" css="RightBtn">详情</@f.a>
    {{# if('${currentUserId}'==d.createBy){ }}
    <@f.a alias="scan_wxwgcpjyxx302" event="del" css="RightBtn">删除</@f.a>
    {{#  } }}
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form', 'common', 'publicMethods', 'jquery', 'layer','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        common.tableSort('wQbdOutsourceCheckTable');
        var tableH = publicMethods.tabHeight();
        //第一个实例
        table.render({
            elem: '#wQbdOutsourceCheckTable'
            ,height:tableH
            ,url: '${ctx}/qbdms/wQbdOutsourceCheck/list'
            ,page: true //开启分页
            ,toolbar: '#wQbdOutsourceCheckHeaderToolsBar'
            ,method: 'post'
            ,defaultToolbar: ['']
            ,autoSort: false //是否排序
            ,cols: [[ //表头
                {type: 'checkbox', fixed: 'left'}
                ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
                    ,{field: 'id', title: '主键',hide:true,sort:false, sortname: 'id'}
                    ,{field: 'fillman', title: '填写人',hide:true,sort:false, sortname: 'fillman'}
                    ,{field: 'filldept', title: '填写部门',hide:true,sort:false, sortname: 'filldept'}
                    ,{field: 'filldate', title: '填写日期',hide:true,sort:false, sortname: 'filldate'}
                    ,{field: 'fillmanaccount', title: '填写人账号',hide:true,sort:false, sortname: 'fillmanaccount'}
                    ,{field: 'filldeptid', title: '填写部门id',hide:true,sort:false, sortname: 'filldeptid'}
                    ,{field: 'filldepthospital', title: '填写人集团',hide:true,sort:false, sortname: 'filldepthospital'}
                    ,{field: 'filldepthospitalid', title: '填写集团id',hide:true,sort:false, sortname: 'filldepthospitalid'}
                    ,{field: 'belongdeptname', title: '所属部门',hide:true,sort:false, sortname: 'belongdeptname'}
                    ,{field: 'secret', title: '密级',hide:true,sort:false, sortname: 'secret'}
                    ,{field: 'productnum', title: '编号',sort:false, sortname: 'productnum'}
                    ,{field: 'model', title: '型号',sort:false, sortname: 'model'}
                    ,{field: 'productname', title: '产品名称',sort:false, sortname: 'productname'}
                    ,{field: 'productsymbol', title: '产品代号',hide:true,sort:false, sortname: 'productsymbol'}
                    ,{field: 'productsum', title: '产品数量',hide:true,sort:false, sortname: 'productsum'}
                    ,{field: 'manufacturer', title: '生产厂家',hide:true,sort:false, sortname: 'manufacturer'}
                    ,{field: 'checkbase', title: '验收依据文件',hide:true,sort:false, sortname: 'checkbase'}
                    ,{field: 'supportunit', title: '配套单位',hide:true,sort:false, sortname: 'supportunit'}
                    ,{field: 'supportunitid', title: '配套单位id',hide:true,sort:false, sortname: 'supportunitid'}
                    //如需转换为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.checkdate,"1");
                    //如需转换为HH:mm:ss: return commons.timeData(d.checkdate,"2");
                    // 当前转换后的格式为yyyy-MM-dd: return commons.timeData(d.checkdate);
                    ,{field: 'checkdate', title: '下厂验收时间',sort:false, sortname: 'checkdate',templet: function (d) {
                    return publicMethods.timeData(d.checkdate);
                }}
                    ,{field: 'checkperson', title: '下厂验收人员',hide:true,sort:false, sortname: 'checkperson'}
                    ,{field: 'checkpersonid', title: '下厂验收人员id',hide:true,sort:false, sortname: 'checkpersonid'}
                    ,{field: 'checkresult', title: '验收结论',sort:false, sortname: 'checkresult'}
                    //如需转换为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.recheckdate,"1");
                    //如需转换为HH:mm:ss: return commons.timeData(d.recheckdate,"2");
                    // 当前转换后的格式为yyyy-MM-dd: return commons.timeData(d.recheckdate);
                    ,{field: 'recheckdate', title: '入所复验时间',sort:false, sortname: 'recheckdate',templet: function (d) {
                    return publicMethods.timeData(d.recheckdate);
                }}
                    ,{field: 'recheckperson', title: '入所复验人员',hide:true,sort:false, sortname: 'recheckperson'}
                    ,{field: 'recheckpersonid', title: '入所复验人员id',hide:true,sort:false, sortname: 'recheckpersonid'}
                    ,{field: 'recheckresult', title: '复验结论',sort:false, sortname: 'recheckresult'}
                    ,{field: 'unqualifiedinfo', title: '不合格内容简述',hide:true,sort:false, sortname: 'unqualifiedinfo'}
                    ,{field: 'checkrecord', title: '检验记录',hide:true,sort:false, sortname: 'checkrecord'}
                    ,{field: 'tenantId', title: '租户Id',hide:true,sort:false, sortname: 'tenantid'}
                    ,{field: 'createBy', title: '创建人',hide:true,sort:false, sortname: 'createby'}
                    //如需转换为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.createTime,"1");
                    //如需转换为HH:mm:ss: return commons.timeData(d.createTime,"2");
                    // 当前转换后的格式为yyyy-MM-dd: return commons.timeData(d.createTime);
                    ,{field: 'createTime', title: '创建时间',hide:true,sort:false, sortname: 'createtime',templet: function (d) {
                    return publicMethods.timeData(d.createTime);
                }}
                    ,{field: 'updateBy', title: '更新人',hide:true,sort:false, sortname: 'updateby'}
                    //如需转换为:yyyy-MM-dd HH:mm:ss: return commons.timeData(d.updateTime,"1");
                    //如需转换为HH:mm:ss: return commons.timeData(d.updateTime,"2");
                    // 当前转换后的格式为yyyy-MM-dd: return commons.timeData(d.updateTime);
                    ,{field: 'updateTime', title: '更新时间',hide:true,sort:false, sortname: 'updatetime',templet: function (d) {
                    return publicMethods.timeData(d.updateTime);
                }}
                ,{
                    fixed: 'right',
                    align: 'center',
                    title: '管理',
                    toolbar: '#wQbdOutsourceCheckRightToolsBar'
                }
            ]],done:function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');
            }
        });

        dateReflash()
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wQbdOutsourceCheckTable',true);
        function dateReflash() {
            publicMethods.reflashDate({startName:'.start_time1',endName:'.end_time1'});
            publicMethods.reflashDate({startName:'.start_time2',endName:'.end_time2'});
        }

        function reflashQuery(isClear) {
            common.tableConditionRender("wQbdOutsourceCheckTable","wQbdOutsourceCheckQueryForm",{where:{}},isClear, false, 20);
            initQueryCol();
        }

        function initQueryCol(){
            var xhdh = eval('${wQbdXhdhs}'); //型号代号
            var initXHDH = function(optionObj, item){
                optionObj.text = item.fModelcode;
                optionObj.value = item.fModelcode;
                optionObj.setAttribute("xhmc", item.fModelname);
            };
            common.initDicData("Q_model_S", xhdh, "", initXHDH);

            var ysjlList = eval('${ysjlList}'); //验收结论
            common.initDicData("checkresult", ysjlList, "");
            common.initDicData("recheckresult", ysjlList, "");
        }

        table.on('toolbar(wQbdOutsourceCheckTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/wQbdOutsourceCheck/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部?'),{title: false,skin: 'confirm-class'},function (index) {
                            layer.close(index);
                            var url = '${ctx}/qbdms/wQbdOutsourceCheck/exportData';
                            var param = "";
                            $("form[lay-filter='wQbdOutsourceCheckQueryForm']").find(".filter-value").each(function (i, value) {
                                param += "&" + this.name + "=" + this.value
                            });
                            open(url, param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = '${ctx}/qbdms/wQbdOutsourceCheck/exportData';
                            open(url, "&id=" + ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wQbdOutsourceCheckTable',"/qbdms/wQbdOutsourceCheck/importData",false,"");
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wQbdOutsourceCheckTable');
                    dateReflash();
                    form.render();
                    break;
                case "report":
                    var ids = "";
                    for (var i = 0; i < data.length; i++) {
                        ids += data[i].id + ",";
                    }
                    //业务表名,勾选数据主键,流程key,table标签lay-filter属性值,form标签lay-filter属性值,是否允许重复上报,页面所在包名,流程定义id
                    common.report("w_qbd_outsource_check", ids, "plantToHospital", "wQbdOutsourceCheckTable", "wQbdOutsourceCheckQueryForm", false, "wQbdOutsourceCheck", "plantToHospital:1:72d05d40362249118c5453aa60c6da90");
                    dateReflash();
                    break;
            };
        });

        table.on('tool(wQbdOutsourceCheckTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":

                    window.location.href = '${ctx}/qbdms/wQbdOutsourceCheck/view/add?id='+data.id;
                    break;
                case "particulars":

                    window.location.href = '${ctx}/qbdms/wQbdOutsourceCheck/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.confirm(publicMethods.confirmStyle("请先选择一行数据!"),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'},function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "${ctx}/qbdms/wQbdOutsourceCheck/del",
                        type: "post",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.confirm(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }

        var xhdh = eval('${wQbdXhdhs}'); //型号代号
        var initXHDH = function(optionObj, item){
            optionObj.text = item.fModelcode;
            optionObj.value = item.fModelcode;
            optionObj.setAttribute("xhmc", item.fModelname);
        };
        common.initDicData("Q_model_S", xhdh, "", initXHDH);
        var ysjlList = eval('${ysjlList}'); //验收结论
        common.initDicData("checkresult", ysjlList, "");
        common.initDicData("recheckresult", ysjlList, "");

        window.Initialization = function () {
            dateReflash();
            reflashQuery(true);
        };
        /*刷新时间控件*/
        dateReflash();
        common.tableSort("wQbdOutsourceCheckTable",{show:window.Initialization});

        function open(url, param) {
            var curUrl = url;
            layer.open({
                type: 2,
                area: ['700px', '520px'],
                title: ['自定义导出', 'font-size:14px;'],
                content: '${ctx}/qbdms/wQbdOutsourceCheck/view/export',
                btnAlign: 'c',
                skin: 'qbdms-layerFormBtn',
                btn: ['确定', '取消'],
                yes: function (index, layero) {
                    url = curUrl;
                    var iframeWin = window["layui-layer-iframe" + index];
                    var data = iframeWin.getData();
                    if (data) {
                        url = url + "?data=" + JSON.stringify(data) + param;
                        window.location.href = encodeURI(url)
                    }
                }
            });
        }
    });
</script>
</body>
</html>